package com.itheima;

import com.itheima.pojo.User;
import jdk.nashorn.internal.objects.annotations.Where;

import java.util.*;

public class ComparatorDemo1 {
    public static void main(String[] args) {
        List<User> list=new ArrayList<>();
        list.add(new User("李白",20,"北京"));
        list.add(new User("杜甫",25,"上海"));
        list.add(new User("李白",17,"天津"));

       /* Collections.sort(list, new Comparator<User>() {
            @Override
            public int compare(User o1, User o2) {
                return o2.getAge()-o1.getAge();
            }
        });*/
       List<Integer> list2=new ArrayList<>();
       Collections.addAll(list2,10,8,9,2,7,4,11,15,18,14,20);
       Collections.sort(list2);

       for(Integer integer:list2){
           System.out.println(integer);
       }

        //获取迭代器
        Iterator<User> iterator = list.iterator();

        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }
    }
}
